/**
 * 
 */
package soa.security.domain;

import org.springframework.ldap.odm.annotations.DnAttribute;
import org.springframework.ldap.odm.annotations.Entry;
import org.springframework.ldap.odm.annotations.Id;
import org.springframework.ldap.support.LdapNameBuilder;
import soa.security.Constants;

import javax.naming.Name;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * 应用系统模型
 * @author CY 2015-11-6 10:48:31
 *
 */
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@Entry(objectClasses = { "zjtzsw-applsystem", "zjtzsw-complex" })
public final class Applsystem extends SoaComplex {

	private static final long serialVersionUID = -6052240517163828525L;

	@XmlTransient
	@Id
	private Name dn;

	@DnAttribute(value = "bid")
	private String bid;

	/**
	 * 系统名称
	 */
	private String sname;
	
	/**
	 * 系统路径
	 */
	private String url;
	
	/**
	 * 系统logo
	 */
	private String logo;
	
	/**
	 * 系统描述
	 */
	private String sdescription;

	/**
	 * 排序
	 */
	private int priority;

	/**
	 * 创建时间
	 */
	private String createTime;
	
	/**
	 * 页面是否disable状态
	 */
	private String status;

	/**
	 * 应用系统的key
	 */
	private String appkey;

	/**
	 * 补充页面地址
	 */
	private String bcymUrl;

	/**
	 * 补充前置条件，0-已注册，1-已实名
	 */
	private String bcymCond;

	public Applsystem() {
	}
	
	public Applsystem(String bid, String sname) {
		super();
		this.bid = bid;
		this.sname = sname;
	}
	
	public Applsystem(String bid, String sname, String logo, String url, String sdescription) {
		super();
		this.bid = bid;
		this.sname = sname;
		this.logo = logo;
		this.url = url;
		this.sdescription = sdescription;
	}

	public String getBid() {
		return bid;
	}
	public void setBid(String bid) {
		this.bid = bid;
	}

	public static Applsystem build(String bid, String sname) {
		return new Applsystem(bid, sname);
	}

	public Name buildDn(Name baseDn) {
		return LdapNameBuilder.newInstance(baseDn).add(Constants.BID, getBid())
				.build();
	}

	public Name getDn() {
		return dn;
	}

	public void setDn(Name dn) {
		this.dn = dn;
	}

	public String getSname() {
		return sname;
	}

	public void setSname(String sname) {
		this.sname = sname;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getLogo() {
		return logo;
	}

	public void setLogo(String logo) {
		this.logo = logo;
	}

	public String getSdescription() {
		return sdescription;
	}

	public void setSdescription(String sdescription) {
		this.sdescription = sdescription;
	}

	public int getPriority() {
		return priority;
	}

	public void setPriority(int priority) {
		this.priority = priority;
	}

	public String getCreateTime() {
		return createTime;
	}

	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}

	public String getAppkey() {
		return appkey;
	}

	public void setAppkey(String appkey) {
		this.appkey = appkey;
	}

	@Override
	public String toString() {
		return "Applsystem bid[" + this.getBid() + "]";
	}

	public String getBcymUrl() {
		return bcymUrl;
	}

	public void setBcymUrl(String bcymUrl) {
		this.bcymUrl = bcymUrl;
	}

	public String getBcymCond() {
		return bcymCond;
	}

	public void setBcymCond(String bcymCond) {
		this.bcymCond = bcymCond;
	}

	@XmlRootElement
	@XmlAccessorType(XmlAccessType.FIELD)
	public static class Applsystems {
		protected List<Applsystem> applsystem = new ArrayList<Applsystem>();

		public List<Applsystem> getApplsystem() {
			return this.applsystem;
		}

		public void addApplsystem(Applsystem applsystem) {
			this.applsystem.add(applsystem);
		}

		public boolean addAll(Collection<? extends Applsystem> c) {
			return applsystem.addAll(c);
		}
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

}
